<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>驳回订单页面</title>
    <script src="js/axios.min.js"></script>
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/vue.js"></script>
    <script src="layui/layui.js"></script>
    <script src="js/vue-router.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <link rel="stylesheet" href="css/goods.css"/>
    <link rel="stylesheet" href="/static/build/layui.css" media="all">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<blockquote class="layui-elem-quote">选择想要驳回的订单</blockquote>

<form class="layui-form" action="">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md3">
            <div class="grid-demo grid-demo-bg1">
                &nbsp;
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="grid-demo">
                <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入订单编号" class="layui-input">
            </div>
        </div>
        <div class="layui-col-md3">
            <div class="grid-demo grid-demo-bg1">
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">确定</button>
            </div>
        </div>
    </div>
</form>

<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>
        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>
        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>
    </div>
</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">接受</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">驳回</a>
</script>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->

<script>
    layui.use('table', function(){
        var table = layui.table;

        table.render({
            elem: '#test'
            ,url:'http://47.94.138.204:7790/order/checkallorder'
            ,toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '订单数据表'


            /*

            [
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            {"usermame":"11","id":"1212"},
            ]

            * */

            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'oid', title:'订单编号', width:100, fixed: 'left', unresize: true, sort: true}
                ,{field:'gid', title:'商品编号', width:100, fixed: 'left', unresize: true, sort: true}
                ,{field:'otime', title:'下单时间', width:190, edit: 'text'}
                ,{field:'num', title:'商品数量', width:100, edit: 'text'}
                ,{field:'price', title:'商品总价', width:100, edit: 'text', sort: true}
                ,{field:'dprice', title:'优惠钱数', width:100, edit: 'text', sort: true}
                ,{field:'rprice', title:'实付价格', width:100, edit: 'text', sort: true}
                ,{field:'uid', title:'用户id', width:100, edit: 'text', sort: true}
                ,{field:'ostate', title:'订单状态', width:100, edit: 'text', sort: true}
                ,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
            ]]
            ,page: true
        });

        //头工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layer.alert(JSON.stringify(data));
                    break;
                case 'getCheckLength':
                    var data = checkStatus.data;
                    layer.msg('选中了：'+ data.length + ' 个');
                    break;
                case 'isAll':
                    layer.msg(checkStatus.isAll ? '全选': '未全选');
                    break;

                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //console.log(obj)
            if(obj.event === 'del'){
                layer.confirm('确定驳回？', function(index){

                    $.ajax({
                        type:"GET",
                        url:"http://47.94.138.204:7790/order/refuseorder?oid=" + obj.data.oid ,
                        success:function(data){
                            alert("http://127.0.0.1:7747/order/refuseorder?oid=" + obj.data.oid )
                        },
                    });
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                // layer.prompt({
                //     formType: 2
                //     ,value: data.email
                // }, function(value, index){
                //     obj.update({
                //         email: value
                //     });
                //     $.ajax({
                //         type:"GET",
                //         url:"http://127.0.0.1:7747/goods/updategoods?sid=" + obj.data.sid +"&type=" + obj.data.type+"&name="+obj.data.name+"&price="+obj.data.price+"&brand="+obj.data.brand+"&remainnum="+obj.data.remainnum+"&avatar_url="+obj.data.avatar_url,
                //         success:function(data){
                //             alert("http://127.0.0.1:7747/admin/userroot?sid=" + obj.data.id +"&root=" + value)
                //         },
                //     });
                //     layer.close(index);
                // });
                layer.confirm('确定接受？', );
                $.ajax({
                    type:"GET",
                    url:"http://47.94.138.204:7790/order/acceptorder?oid=" + obj.data.oid ,
                    success:function(data){
                        alert("http://127.0.0.1:7747/admin/userroot?sid=" + obj.data.id +"&root=" + value)
                    },
                });
            }
        });
    });
</script>

</body>
</html>